﻿using RM.Weighing.Models;
using Sunny.UI;
using System;

namespace RM.Weighing.Page
{
    public partial class UISettings : UIPage
    {
        public UISettings()
        {
            InitializeComponent();
        }


        private void UISettings_Initialize(object sender, EventArgs e)
        {
            cb_sn.DataSource = SerialPortTools.COMList();
            uiComboBox1.Items.Clear();
            foreach (string sPrint in GodexPrinter.GetDriverPrinter())//获取计算机安装所有打印机的名称
            {
                uiComboBox1.Items.Add(sPrint);
            }


            if (IniSettings.Current.SerialName != "")
            {
                cb_sn.Text = IniSettings.Current.SerialName;
            }
            else
            {
                cb_sn.SelectedIndex = 0;
            }
            if (IniSettings.Current.BQPrint != "")
            {
                uiComboBox1.Text = IniSettings.Current.BQPrint;
            }
            else
            {
                uiComboBox1.SelectedIndex = 0;
            }
        }

        private void uiButton2_Click(object sender, EventArgs e)
        {
            IniSettings.Current.SerialName = cb_sn.Text;
            IniSettings.Current.BQPrint = uiComboBox1.Text;
            IniSettings.Current.Save();
            ShowSuccessTip("保存成功！");
        }
    }
}
